import Vue from 'vue'
import Vuex from 'vuex'
import cart from './cart'
import login from './login'
Vue.use(Vuex)

const myPlugin = (store) => {
  store.subscribe((mutation, state) => {
    console.log('mutation:', mutation, state)
    localStorage.setItem('state', JSON.stringify(state))
  })
}

export default new Vuex.Store({
  plugins: [myPlugin],
  modules: { cart, login },
})
